﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SystemManage_SystemParamConfig_ProductColorSizeConfig : System.Web.UI.Page
{
    private Model.SYSPARAM SysParam
    {
        get
        {
            Model.SYSPARAM sysParam = null;
            if (ViewState["SysParam"] != null)
            {
                sysParam = (Model.SYSPARAM)ViewState["SysParam"];
            }
            return sysParam;
        }
        set
        {
            ViewState["SysParam"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("100100105");
        if (!IsPostBack)
        {
            this.SysParam = new BLL.SYSPARAM().GetModel("004");
            if (this.SysParam != null)
            {
                chkSwitch.Checked = this.SysParam.SP_PARAM1 == 1 ? true : false;
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Check.CheckPermission("100100105", "00017"))
        {
            Share.Alert(this.Page, "无权操作"); return;
        }
        if (this.SysParam != null)
        {
            this.SysParam.SP_PARAM1 = chkSwitch.Checked ? 1 : 0;

            this.SysParam.SP_PARAM9 = DateTime.Now;
            this.SysParam.SP_PARAM10 = DateTime.Now;
            this.SysParam.SP_PARAM11 = DateTime.Now;
            this.SysParam.SP_PARAM12 = DateTime.Now;

            if (new BLL.SYSPARAM().Update(this.SysParam))
            {
                new BLL.SYSPARAM().UpdatetProductUpDownColorSizeConfigCache(chkSwitch.Checked);
                Share.InsertLog("100100105", "00017");
                Response.Write("<script>alert('保存成功');</script>");
            }
            else
            {
                Response.Write("<script>alert('保存失败');</script>");
            }
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("ProductColorSizeConfig.aspx");
    }
}
